"""
List of activation from Huggingface in paddle.
"""

import math
import paddle as pp
from paddle import nn


def gelu_python(x): return x * 0.5 * (1.0 + pp.erf(x / math.sqrt(2.0)))
def gelu_new(x): return 0.5 * x * (1.0 + pp.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * pp.pow(x, 3.0))))
def gelu_fast(x): return 0.5 * x * (1.0 + pp.tanh(x * 0.7978845608 * (1.0 + 0.044715 * x * x)))
def quick_gelu(x): return x * nn.functional.sigmoid(1.702 * x)
def linear_act(x): return x

ACT2FN = {
    "relu": nn.functional.relu,
    "silu": nn.functional.silu,
    "swish": nn.functional.silu,
    "gelu": nn.functional.gelu,
    "tanh": pp.tanh,
    "gelu_python": gelu_python,
    "gelu_new": gelu_new,
    "gelu_fast": gelu_fast,
    "quick_gelu": quick_gelu,
    "mish": nn.functional.mish,
    "linear": linear_act,
    "sigmoid": pp.nn.functional.sigmoid,
}

